﻿<UserControl x:Class="InseSoft.Views.Controls.LoginEdit"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"             
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:viewModels="clr-namespace:InseSoft.ViewModels"
             mc:Ignorable="d" 
             Height="145" Width="320">
    <UserControl.Resources>
        <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
        <Style TargetType="TextBlock">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="HorizontalAlignment" Value="Left" />
        </Style>
        <Style TargetType="ComboBox">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="HorizontalAlignment" Value="Left" />
        </Style>
        <Style TargetType="TextBox">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="Height" Value="23" />
        </Style>
        <Style TargetType="PasswordBox">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="Height" Value="23" />
        </Style>
        <Style TargetType="Button">
            <Setter Property="Height" Value="25" />
            <Setter Property="Width" Value="80" />
            <Setter Property="HorizontalAlignment" Value="Right" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Margin" Value="0,0,10,0" />
        </Style>
    </UserControl.Resources>
    <Border BorderBrush="Gray" BorderThickness="1" CornerRadius="15" Background="GhostWhite" Opacity="10" >
        <StackPanel Margin="5" d:DataContext="{d:DesignInstance {x:Type viewModels:LoginViewModel}}">
            <Grid FocusManager.FocusedElement="{Binding ElementName=UserTextBox}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="90" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="27" />
                    <RowDefinition Height="27" />
                    <RowDefinition Height="27" />
                    <RowDefinition Height="10" />
                </Grid.RowDefinitions>
                <TextBlock Text="Usuario" Grid.Row="0"/>
                <TextBlock Text="Clave" Grid.Row="1" />
                <TextBlock Text="Empresa" Grid.Row="2" />
                <TextBox Name="UserTextBox" Grid.Row="0" Grid.Column="1" Width="150" MaxLength="50" Text="{Binding Path=User}"/>
                <PasswordBox Name="PasswordTextBox" Grid.Row="1" Grid.Column="1" Width="150" MaxLength="50" />
                <ComboBox Grid.Row="2" Grid.Column="1" Width="150" ItemsSource="{Binding Empresas}" SelectedIndex="0" SelectedItem="{Binding SelectedEmpresa, Mode=TwoWay}">
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Nombre}" TextTrimming="CharacterEllipsis" />
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
            </Grid>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="200" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="35" />
                    <RowDefinition Height="10" />
                </Grid.RowDefinitions>
                <TextBlock Text="Usuario o clave inválida!" Foreground="Red"
                           Visibility="{Binding InvalidPassword, Converter={StaticResource BooleanToVisibilityConverter}}"
                           />
                <Button Content="Aceptar" 
                        Grid.Column="1"
                        Command="{Binding AcceptCommand}" 
                        IsDefault="True"
                        CommandParameter="{Binding ElementName=PasswordTextBox}"/>
            </Grid>

            <!--<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Content="Aceptar" 
                        HorizontalAlignment="Right"
                        Command="{Binding AcceptCommand}" 
                        CommandParameter="{Binding ElementName=PasswordTextBox}"/>
            </StackPanel>-->
        </StackPanel>
    </Border>
</UserControl>
